#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File    :   interence_for_pig.py    
@Contact :   raogx.vip@hotmail.com
@License :   (C)Copyright 2017-2018, Liugroup-NLPR-CASIA

@Modify Time      @Author    @Version    @Desciption
------------      -------    --------    -----------
2022/5/22 1:20 下午   caijiahao      1.0         Bytedancer
'''

# import lib
import pandas as pd
import os
import numpy as np
import sys

sys.path.append('../')

# 得到猪只数据集
def run_inference_for_images_per_image_for_pig(image_folder, np_boxes_path, detect_result_path):
    path_box_lists = []

    # 1、读取目标检测结果
    detect_result = pd.read_csv(detect_result_path)

    # 2、写入初始化数据集
    for row_index in range(len(detect_result)):
        frame_path = os.path.join(image_folder, detect_result.iloc[row_index][0] + '.jpg')
        path_box_lists.append([frame_path,
                               detect_result.iloc[row_index][1],
                               detect_result.iloc[row_index][2],
                               detect_result.iloc[row_index][3],
                               detect_result.iloc[row_index][4],
                               'normal'])
        print('i = {} / {}'.format(row_index, len(detect_result)))
    np.save(np_boxes_path, path_box_lists)
    print('finish boxes detection!')


if __name__ == '__main__':
    image_path = '../object_detection/data/'
    np_boxes_path = '../result/np_boxes_path'
    detect_result_path = '../object_detection/data/result2csv.csv'
    run_inference_for_images_per_image_for_pig(image_path, np_boxes_path, detect_result_path)
